
<%@page import="Controller.*" %>
<%@page import="Model.*" %>
<%@page import="java.util.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
    controller_ChuyenTau mTau = new controller_ChuyenTau();
    List<model_ChuyenTau> chuyenTaus = new ArrayList();
%>

<form action="frmChuyenTau_TimKiem.jsp" method="GET" style="text-align: right; margin-top: 10px; padding-right: 10px">
    <select style="width: 200px" name="cmbMACHUYEN">
        <%
            chuyenTaus = mTau.LoadList();
            for (model_ChuyenTau ct : chuyenTaus) {
        %>    
        <option value="<%= ct.getMACHUYEN()%>" >
            <%= ct.getMACHUYEN()%>
        </option>
        <%}%> 
    </select>
    <input type="submit" value="Tìm Kiếm" />
</form>
    
<table>
    <caption><h1>Danh Sách Chuyến Tàu</h1></caption>

    <tr>
        <th>STT</th>
        <th>Mã Chuyến</th>
        <th>Mã Tuyến</th>
        <th>Mã Đ.Tàu</th>
        <th>Thời Gian XP</th>
        <th>Xóa</th>
        <th>Cập Nhật</th>
    </tr>

    <%
        chuyenTaus = mTau.LoadList();
        int i = 0;
        for (model_ChuyenTau ct : chuyenTaus) {
            i++;
    %>
    <tr>
        <td><%= i%></td>     
        <td><%= ct.getMACHUYEN()%></td>       
        <td><%= ct.getMATUYEN()%></td>        
        <td><%= ct.getMADT()%></td>        
        <td><%= ct.getTHOIGIANXP()%></td>       
        <td>
            <a onclick="return confirm('Bạn có chắc chắn!')" href="QL_ChuyenTau/Xoa.jsp?MACHUYEN=<%= ct.getMACHUYEN()%>"> Xóa  </a>
        </td>        
        <td>
            <a href="frmChuyenTau_CapNhat.jsp?MACHUYEN=<%=ct.getMACHUYEN()%>"> Cập nhật </a>
        </td>
    </tr>
    <%}%>   
</table>

<fieldset style="margin-top: 20px; margin-bottom: 10px; margin-right: 50px; margin-left: 50px; background-color: #FFFFCC; color: #FF0000">
    <legend><h3>Thêm Chuyến Tàu</h3></legend>
    <form action="QL_ChuyenTau/Them.jsp" method="POST" style="margin-top: 20px; padding-left: 20px ">
        Mã Chuyến:
        <input type="text" name="txtMACHUYEN" size="19" style="margin-left: 13px"/> (*)<br/>
        Mã Tuyến:
        <select name="cmbMATUYEN" style="width: 150px; margin-left: 21px; margin-top: 10px" >
            <%
                controller_TuyenTau TTau = new controller_TuyenTau();
                List<model_TuyenTau> tuyenTaus = TTau.LoadList();
                for (model_TuyenTau tt : tuyenTaus) {
            %>    
            <option value="<%= tt.getMATUYEN()%>">
                <%= tt.getMATUYEN()%>
            </option>
            <%}%> 
        </select> (*)<br/>
        Mã Đ.Tàu:
        <select name="cmbMADT" style="width: 150px; margin-left: 20px; margin-top: 10px" >
            <%
                controller_DoanTau DTau= new controller_DoanTau();
                List<model_DoanTau> doanTaus = DTau.LoadList();
                for (model_DoanTau dt : doanTaus) {
            %>    
            <option value="<%= dt.getMADT()%>">
                <%= dt.getMADT()%>
            </option>
            <%}%> 
        </select> (*)<br/>
        T.Gian XP:
        <input type="text" name="txtTHOIGIANXP" size="50" style="margin-left: 18px; margin-top: 10px"/> (yyyy/MM/dd)<br/>
        
        <input type="submit" value="Thêm Chuyến Tàu" style="margin-top: 20px; margin-left: 90px"/>
        <input type="reset" value="Reset" />
    </form>
</fieldset>